<!doctype html>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<title>六个核桃</title>
		<meta name="keywords" content="六个核桃" />
		<meta name="description" content="六个核桃" />
		<link href="css/layout.css" rel="stylesheet" type="text/css">
		<link href="css/login.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="js/js.js"></script>
		<script type="text/javascript">
			
			var post="student";
			function setPost() {
				var ans=document.getElementsByName("type");
				for(var i=0;i<ans.length;++i)
				{
					if(ans[i].checked){
						post=ans[i].value;
					}
				}
			}
			
			function getXmlHttpObject(){
				var xmlHttpRequest;
				if(window.ActiveXObject){
					//window.alert("ie");
				}else{
					//window.alert("firefox");
					xmlHttpRequest=new XMLHttpRequest();
				}
				return xmlHttpRequest;
			}
			
			var myXmlHttpRequest;
			var username; var password;
			function checkName(){
				myXmlHttpRequest=getXmlHttpObject();
				username=document.getElementById("username").value;
				password=document.getElementById("password").value;
				if(myXmlHttpRequest){
					var url="http://localhost:8080/StuScoreSystem/Login?method="+post+"Login&&username="+username+"&&password="+password+"";
					//var url="http://localhost:8080/StuScoreSystem/Login?method=adminLogin&&username=admin&&password=123";
					myXmlHttpRequest.open("get",url,true);
					myXmlHttpRequest.onreadystatechange=progress;
					myXmlHttpRequest.send(null);
				}
		
				else{
					window.alert("error");
				}
			}
	
			function progress(){
				if(myXmlHttpRequest.readyState==4){
					var json=myXmlHttpRequest.responseText;
					var json_obj=eval("("+json+")");
					//var json1=JSON.parse(json);
					var state_obj=json_obj.meta;
					if(state_obj.state=="success"){
						if(post=="admin"){
							window.location.href="index.html?username="+username+"";
						}
						else if(post=="teacher"){
							window.location.href="teacher_info.html?username="+username+""
						}
						else{
							window.location.href="studentMain.html?username="+username+"";
						}
					}
					else{
						window.alert("用户名或密码错误");
						location.reload(true);
					}
				}
			}
			
		</script> 
	</head>
	<style>
		.ibar {display: none;}
	</style>
	<body class="login-bg">
		
		<div class="main ">
			<div class="header" style="padding: 0; width: 400px; height: 60px; line-height: 60px; margin: 0 0 0 30px;">
				<h1 style="color:#ababab;">StudentScoreManagementSystem</h2> 
			</div>
			<!--登录-->
			
			<div class="login-dom login-max">
				<div class="logo text-center">
					<a href="#">
					<img src="Images/logo.png" width="180px" height="180px">
					</a>
				</div>
				<div class="div-form jz">
				<div class="login container " id="login">
					
					<form class="login-form" style="padding-top:10px;" action="studentMain.html" method="post" autocomplete="off">
						<div class="login-box border text-big" id="box">
							<div class="name border-bottom">
								<input type="text" placeholder="学号/工号 " id="username" name="username" datatype="*" nullmsg="请填写帐号信息">
							</div>
							<div class="pwd ">
								<input type="password" placeholder="密码" datatype="*" id="password" name="password" nullmsg="请填写帐号密码">
							</div>
							
						</div>
						<div class="mt-20 skin-minimal" style="text-align: center;">
							<div class="radio-box text-big">
								<input  type="radio" onchange="setPost()" id="radio-2" name="type" checked value="student" >学生</input>
							</div>
							<div class="radio-box text-big" >
								<input type="radio" onchange="setPost()" id="radio-3" name="type" value="teacher" >教师</input>
							</div>
							<div class="radio-box text-big">
								<input type="radio" onchange="setPost()" id="radio-1" name="type" value="admin" >管理员</input>
							</div>
						</div>
						<input type="hidden" name="formhash" value="5abb5d21"/>
						<input type="button" onclick="checkName();" class="btn text-center login-btn" value="立即登录">
						
					</form>
					 
				</div>
			</div>
			</div>
			<div class="footer text-center text-big ie" style="color:#000000;">
				Copyright 2017-20XX 六个核桃小组 版权所有 <a href="#" target="_blank"></a>
				<span class="margin-left margin-right"></span>
				<script src="#" language="JavaScript"></script>
			</div>
			<div class="popupDom">
				<div class="popup text-default">
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="Js/Validform_v5.3.2_min.js"></script>
	<script type="text/javascript">
		function popup_msg(msg) {
			$(".popup").html("" + msg + "");
			$(".popupDom").animate({
				"top": "0px"
			}, 400);
			setTimeout(function() {
				$(".popupDom").animate({
					"top": "-40px"
				}, 400);
			}, 2000);
		}

		/*动画（注册）*/
		$(document).ready(function(e) {
			// $("input[name=username]").focus();
			// $('.login-form').Validform({
			// 	ajaxPost: true,
			// 	tiptype: function(msg) {
			// 		if (msg) popup_msg('' + msg + '');
			// 	},
			// 	callback: function(ret) {
			// 		popup_msg('' + ret.info + '');
			// 		if (ret.status == 1) {
			// 			if (ret.uc_user_synlogin) {
			// 				$("body").append(ret.uc_user_synlogin);
			// 			}
			// 			setTimeout("window.location='" + ret.url + "'", 2000);
			// 		}
			// 	}
			// })

		});
	</script>

</html>